package com.weilele.leisure.time.ui.fragment


import com.weilele.base.library.BaseViewModel
import com.weilele.leisure.time.R
import com.weilele.leisure.time.ui.SettingConfig
import com.weilele.leisure.time.ui.module.main.HomePagerFragment
import com.weilele.leisure.time.ui.module.mine.MineFragment
import com.weilele.leisure.video_factory.ui.module.video_factory.VideoFactoryFragment
import com.weilele.mvvm.base.livedata.createStatusListLiveData
import com.weilele.mvvm.base.livedata.success
import com.weilele.mvvm.utils.activity.getResString

class HomeViewModel : BaseViewModel() {
    private val allPages by lazy {
        mutableListOf(
            HomePageBean(
                1,
                HomePagerFragment::class.java,
                getResString(R.string.title_video).toString(),
                R.drawable.icon_home_menu_video
            ) { SettingConfig.homeEnableVideoPager },
            HomePageBean(
                2,
                VideoFactoryFragment::class.java,
                getResString(R.string.title_tools).toString(),
                R.drawable.icon_home_menu_factory
            ) { true },
            HomePageBean(
                3,
                MineFragment::class.java,
                getResString(R.string.title_mine).toString(),
                R.drawable.icon_home_menu_mine
            ) { true },
        )
    }

    private val pages
        get() = allPages.filter {
            it.enable.invoke()
        }.toMutableList()

    val pagesData = createStatusListLiveData<HomePageBean>().apply {
        success(pages)
    }

    /**
     *更新数据
     */
    fun updatePages() {
        pagesData.success(pages)
    }

}